<template>
  <div class="taskdetail-omnipotent">
    <Loading :loadingShow="taskLoading" type="fix"></Loading>
    <TsContain
      :leftWidth="260"
      :isSiderHide="!isOrderLeft"
      :sessionName="sessionName"
    >
      <template v-slot:navigation>
        <span class="tsfont-left text-action" @click="$back(prevPath.router)">{{ $getFromPage(prevPath.name) }}</span>
      </template>
      <template v-slot:topLeft>
        <div class="taskdetail-top">
          <NavTop
            :prevPath="prevPath"
            :processTaskConfig="processTaskConfig"
            :isEditTitle="isEditTitle"
            :taskTitle="processTaskConfig.title"
            :actionConfig="actionConfig"
            @isTslayout="isTslayout"
            @editTitle="editTitle"
            @changeTitle="changeTitle"
            @toPrevpath="toPrevpath"
          ></NavTop>
   
          <div class="toolbar-right">
            <div class="action-group">
              <!-- 开始_start -->
              <span
                v-if="actionConfig.start"
                :class="{disable: disabledConfig.starting}"
                class="action-item tsfont-play-o"
                @click="startTaskStep('start')"
              >{{ actionConfig.start }}</span>
              <!-- 开始_end -->
              <!-- accept_start -->
              <span
                v-if="actionConfig.accept"
                :class="{disable: disabledConfig.accepting}"
                class="action-item tsfont-play-o"
                @click="startTaskStep('accept')"
              >{{ actionConfig.accept }}</span>
              <!-- accept_end -->
              <!-- 暂存、保存_start -->
              <span
                v-if="actionConfig.save"
                :class="{disable: disabledConfig.saving}"
                class="action-item tsfont-save"
                @click="saveTaskData()"
              >{{ actionConfig.save }}</span>
              <!-- 暂存、保存_end -->
              <!-- 转交_start -->
              <span
                v-if="actionConfig.transfer"
                :class="{disable: disabledConfig.transferring}"
                class="action-item tsfont-arrow-corner-right"
                @click="transferTask"
              >{{ actionConfig.transfer }}</span>
              <!-- 转交_end -->
              <!-- 暂停步骤 -->
              <span
                v-if="actionConfig.pause"
                :class="{disable: disabledConfig.pausing}"
                class="action-item tsfont-pause"
                @click="pauseStep"
              >{{ actionConfig.pause }}</span>
              <!-- 恢复步骤 -->
              <span
                v-if="actionConfig.recover"
                :class="{disable: disabledConfig.recoverstep}"
                class="action-item tsfont-play-o"
                @click="recoverStep"
              >{{ actionConfig.recover }}</span>
              <!-- 查看流程图_start -->
              <span v-if="!pocesstaskview" class="action-item" @click="lookSitemap">
                <Tooltip :content="$t('term.process.viewflowchart')" theme="light">
                  <i class="tsfont-topo"></i>
                </Tooltip>
              </span>
              <!-- 工单关注 -->
              <span
                :class="{disable: disabledConfig.focusing}"
                class="action-item"
                @click="updateFocus"
              >
                <Tooltip v-if="processTaskConfig.isFocus" :content="$t('term.process.notfocustask')" theme="light">
                  <i :class="['text-danger', 'tsfont-heart-s']"></i>
                </Tooltip>
                <Tooltip v-else :content="$t('term.process.focustask')" theme="light">
                  <i :class="['text-danger', 'tsfont-heart-o']"></i>
                </Tooltip>
              </span>
              <!-- 更多操作 -->
              <span v-if="isMoreAction" class="action-item">
                <Dropdown trigger="click" placement="bottom-end">
                  <span class="tsfont-option-vertical"></span>
                  <DropdownMenu slot="list">
                    <!-- 撤回_start -->
                    <DropdownItem v-if="actionConfig.retreat" :disabled="disabledConfig.retreating" @click.native="retreatTaskStep">
                      {{ actionConfig.retreat }}
                    </DropdownItem>
                    <!-- 撤回_end -->
                    <!-- 添加子任务_start -->
                    <DropdownItem v-if="actionConfig.createsubtask" @click.native="addAssist">
                      {{ actionConfig.createsubtask }}
                    </DropdownItem>
                    <!-- 添加子任务_end -->
                    <!--转报  -->
                    <DropdownItem v-if="actionConfig.tranferreport" @click.native="openRanferreport">
                      {{ actionConfig.tranferreport }}
                    </DropdownItem>
                    <!-- 取消_start -->
                    <DropdownItem v-if="actionConfig.abortprocessTask" :disabled="disabledConfig.aborting" @click.native="cancelTask">
                      {{ actionConfig.abortprocessTask }}
                    </DropdownItem>
                    <!-- 取消_end -->
                    <!-- 恢复_start -->
                    <DropdownItem v-if="actionConfig.recoverprocessTask" :disabled="disabledConfig.recovertask" @click.native="recoverTask">
                      {{ actionConfig.recoverprocessTask }}
                    </DropdownItem>
                    <!-- 恢复_end -->
                    <!-- 恢复_start -->
                    <DropdownItem v-if="actionConfig.urge" :disabled="disabledConfig.urging" @click.native="urgeTask">
                      {{ actionConfig.urge }}
                    </DropdownItem>
                    <!-- 恢复_end -->
                    <!-- 复制上报 -->
                    <DropdownItem v-if="actionConfig.copyprocesstask" @click.native="copyProcessTask">
                      {{ actionConfig.copyprocesstask }}
                    </DropdownItem>
                    <!-- 复制上报 -->
                    <DropdownItem v-if="knowledgeConfig && knowledgeConfig.isTransferKnowledge == 1" @click.native="createKnowledge">
                      转为知识文档
                    </DropdownItem>
                  </DropdownMenu>
                </Dropdown>
              </span>
              <!-- 回退s -->
              <span v-if="actionConfig.back && backStepList.length > 1" class="action-item">
                <Button 
                  icon="tsfont tsfont-reply"
                  @click="backTask"
                >{{ actionConfig.back }}</Button>
              </span>
              <span v-if="actionConfig.back && backStepList.length == 1" class="action-item">
                <Button
                  style="max-width:180px"
                  class="overflow"
                  icon="tsfont tsfont-reply"
                  :title="selectBackConfig.name ? selectBackConfig.flowDirection + selectBackConfig.name : null"
                  @click="backTask"
                >{{ actionConfig.back }}</Button>
              </span>
              <!-- 回退_end -->
              <!-- 流转_start -->
              <!-- 接下来步骤大于1个，弹窗选择 -->
              <span v-if="actionConfig.complete && nextStepList.length > 1" class="action-item">
                <Button
                  icon="tsfont tsfont-refresh"
                  type="primary"
                  @click="completeTask"
                >{{ actionConfig.complete }}</Button>
              </span>
              <!-- 接下来步骤1个 直接选择-->
              <span v-if="actionConfig.complete && nextStepList.length == 1" class="action-item">
                <Button
                  icon="tsfont tsfont-refresh"
                  type="primary"
                  :disabled="disabledConfig.completing"
                  :title="nextStepList[0].name ? nextStepList[0].flowDirection + nextStepList[0].name : null"
                  @click="completeStep(nextStepList[0])"
                >
                  <div class="overflow" style="max-width:150px">{{ nextStepList[0].aliasName || actionConfig.complete }}</div>
                </Button>
              </span>
              <!-- 流转_end -->
              <!-- 评分前回退 -->
              <span v-if="actionConfig.redo" class="action-item">
                <Button
                  icon="tsfont tsfont-reply"
                  @click="redoTask"
                >{{ actionConfig.redo }}</Button>
              </span>
            </div>
          </div>
        </div>
      </template>
      <template v-slot:left>
        <slot></slot>
      </template>
      <template v-slot:content>
        <div class="task-main">
          <template v-if="(processTaskStepRemindList && processTaskStepRemindList.length > 0) || (processTaskConfig.tranferReportProcessTaskList && processTaskConfig.tranferReportProcessTaskList.length > 0)">
            <TaskAlert :list="processTaskStepRemindList" :tranferReportProcessTaskList="processTaskConfig.tranferReportProcessTaskList" @getTaskAlertHeight="(taskHeight) => taskAlertHeight = taskHeight"></TaskAlert>
          </template>
          <TsContain
            :rightWidth="290"
            :hasContentPadding="false"
            hideHeader
            :isSiderHide="!isOrderRight"
            siderPosition="right"
            :rightBtn="true"
            @rightSiderToggle="rightSiderToggle"
          >
            <template v-slot:content>
              <div
                v-if="actionConfig.pocesstaskview && processTaskConfig && startProcessTaskStep"
                class="pt-nm"
                style="overflow-y: scroll;"
                :style="{height: `calc(100% - ${taskAlertHeight}px)`}"
              >
                <CenterDetail
                  ref="TaskCenterDetail"
                  :actionConfig="actionConfig"
                  :formConfig="formConfig"
                  :processTaskConfig="processTaskConfig"
                  :processTaskStepConfig="processTaskStepConfig"
                  :formEdit="formEdit"
                  :showActive="showActive"
                  :addAssist="addAssist"
                  :startProcessTaskStep="startProcessTaskStep"
                  :defaultProcessTaskId="processTaskId"
                  :defaultProcessTaskStepId="processTaskStepId"
                  :replaceableTextConfig="replaceableTextConfig"
                  :priorityList="priorityList"
                  @update="update"
                  @changeDisableCommet="(val)=>{
                    isDisableCommet = val
                  }"
                >
                  <template v-slot:automatic>
                    <div v-if="processTaskStepConfig && processTaskStepConfig.processTaskStepData && processTaskStepConfig.processTaskStepData.isStepUser == 1">
                      <div v-if="processTaskStepConfig.processTaskStepData.requestAudit && JSON.stringify(processTaskStepConfig.processTaskStepData.requestAudit) != '{}'" class="request-audit">
                        <div class="automatic-title">
                          <span>{{ $t('term.process.callrecord') }}</span>
                          <CommonStatus
                            v-if="processTaskStepConfig.processTaskStepData.requestAudit.status"
                            :statusName="processTaskStepConfig.processTaskStepData.requestAudit.status.text"
                            :statusValue="processTaskStepConfig.processTaskStepData.requestAudit.status.value"
                            class="automatic-status"
                          ></CommonStatus>
                        </div>
                        <AutoDetail :defaultStepData="processTaskStepConfig.processTaskStepData.requestAudit" :isShowFailed="processTaskStepConfig.processTaskStepData.requestAudit.status.value == 'failed' ? true : false" type="requestAudit"></AutoDetail>
                        <div v-if="processTaskStepConfig.processTaskStepData.requestAudit.isRetry" class="retry-btn">
                          <Button type="primary" ghost @click="autoRetry()">{{ $t('page.retry') }}</Button>
                        </div>
                      </div>
                      <div v-if="processTaskStepConfig.processTaskStepData.callbackAudit && JSON.stringify(processTaskStepConfig.processTaskStepData.callbackAudit) != '{}'" class="callback-audit border-color">
                        <div class="automatic-title">
                          <span>{{ $t('term.process.callbackrecord') }}</span>
                          <CommonStatus
                            v-if="processTaskStepConfig.processTaskStepData.callbackAudit.status"
                            :statusName="processTaskStepConfig.processTaskStepData.callbackAudit.status.text"
                            :statusValue="processTaskStepConfig.processTaskStepData.callbackAudit.status.value"
                            class="automatic-status"
                          ></CommonStatus>
                        </div>
                        <AutoDetail :defaultStepData="processTaskStepConfig.processTaskStepData.callbackAudit" :isShowFailed="processTaskStepConfig.processTaskStepData.callbackAudit.status.value == 'failed' ? true : false" type="callbackAudit">></AutoDetail>
                        <div v-if="processTaskStepConfig.processTaskStepData.callbackAudit.isRetry" class="retry-btn">
                          <Button type="primary" ghost @click="autoRetry()">{{ $t('page.retry') }}</Button>
                        </div>
                      </div>
                    </div>
                  </template>
                  <div slot="replyBtn">
                    <!-- 回退/流转按钮 -->
                    <FooterOperationBtn
                      :actionConfig="actionConfig"
                      :nextStepList="nextStepList"
                      :disabledConfig="disabledConfig"
                      :backStepList="backStepList"
                      :selectBackConfig="selectBackConfig"
                      :currentProcessTaskStep="processTask.currentProcessTaskStep"
                      :isDisableCommet="isDisableCommet"
                      @completeTask="completeTask"
                      @completeStep="completeStep"
                      @backTask="backTask"
                      @comment="comment"
                    ></FooterOperationBtn>
                  </div>
                </CenterDetail>
              </div>
            </template>
            <template v-slot:right>
              <RightSetting
                ref="RightSetting"
                :actionConfig="actionConfig"
                :addAssist="addAssist"
                :processTaskConfig="processTaskConfig"
                :knowledgeConfig="knowledgeConfig"
                :replaceableTextConfig="replaceableTextConfig"
                :isOrderRight="isOrderRight"
                :priorityList="priorityList"
                @updateActiveStep="updateActiveStep"
              ></RightSetting>
            </template>
          </TsContain>
        </div>
      </template>
    </TsContain>
    <!-- 流转 -->
    <TsDialog
      type="modal"
      :isShow.sync="completeModal"
      :className="stepDialogClass"
      :title="actionConfig.complete"
      @on-ok="completeOk"
    >
      <template>
        <div class="step-list" style="max-height:400px">
          <div v-if="selectStepConfig">
            <StepSelect :id="selectStepConfig.id" :list="nextStepList" @selecStep="selecStep"></StepSelect>
            <div v-if="assignableWorkerStepList.length > 0" class="pb-nm">
              <TsFormItem
                v-for="(item, index) in assignableWorkerStepList"
                :key="index"
                :label="$t('term.process.selectaskuser', {target: item.name})"
                :validateList="item.isRequired ? validateList : []"
                class="input-border"
                labelPosition="top"
              >
                <UserSelect
                  v-model="item.value"
                  transfer
                  :groupList="assignGroupList"
                  :validateList="item.isRequired ? validateList : []"
                ></UserSelect>
              </TsFormItem>
            </div>
          </div>
          <TsForm ref="completeForm" :itemList="completeList" labelPosition="top"></TsForm>
        </div>
      </template>
    </TsDialog>
    <!-- 转交 -->
    <TransferDialog
      :isShow.sync="transferModal"
      :processTaskId="processTaskId"
      :processTaskStepId="processTaskStepId"
      :content="transferContent"
    ></TransferDialog>
    <!-- 查看流程图 -->
    <LookSitemapDialog
      ref="isLookSitemap"
      :lookSitemapModel="lookSitemapModel"
      :stepDialogClass="stepDialogClass"
      :tsDialoglookSitemap="tsDialoglookSitemap"
      :sitemapTitle="sitemapTitle"
      :tooltipStyle="tooltipStyle"
      :stepTooltip="stepTooltip"
    ></LookSitemapDialog>
    <!-- 添加子任务 -->
    <TsDialog
      type="modal"
      :isShow.sync="assistModal"
      :title="isEdit ? $t('page.edit') : $t('page.build')"
      :okBtnDisable="disabledConfig.subtasking"
      @on-ok="assistOk()"
      @on-close="assistModal = false"
    >
      <template>
        <div style="width:90%">
          <TsForm
            ref="assistForm"
            :itemList="assistList"
            type="type"
            labelPosition="right"
          ></TsForm>
        </div>
      </template>
    </TsDialog>
    <!-- 校验 -->
    <div v-if="validCardOpen" class="tsscroll-container valid-main">
      <Card style="width:100%;" :padding="0">
        <p slot="title">{{ $t('page.validate') }}</p>
        <a slot="extra" href="javascript:void(0);" @click.prevent="validCardOpen = false">
          <Icon custom="tsfont-close text-title"></Icon>
        </a>
        <CellGroup style="max-height: 340px; overflow: auto;">
          <Cell
            v-for="(item, index) in validList"
            :key="index"
            :title="item.msg"
            @click.native="validItemClick(item.focus)"
          >
            <Icon
              slot="icon"
              :custom="item.icon"
              size="20"
              :color="item.iconColor"
            ></Icon>
          </Cell>
        </CellGroup>
      </Card>
    </div>
    <!-- 撤回 -->
    <TsDialog
      type="modal"
      :isShow.sync="retreatModal"
      :title="actionConfig.retreat"
      :className="stepDialogClass"
      @on-ok="retreatOk"
    >
      <template>
        <div class="step-list">
          <TsForm ref="retreatForm" :itemList="retreatConfig" labelPosition="top">
            <template v-slot:processTaskStepId>
              <StepSelect :id="retreatId" :list="retreatList" @selecStep="retreatStep"></StepSelect>
            </template>
          </TsForm>
        </div>
      </template>
    </TsDialog>
    <!-- 开始 处理-->
    <TsDialog
      type="modal"
      :isShow.sync="startModal"
      class="vertical-center-modal"
      :hasHeader="false"
      :hasFooter="false"
      :className="stepDialogClass"
    >
      <template>
        <div class="submitModelBox">
          <p class="text-grey text-line">{{ $t('term.process.pleselectprioritystep') }}</p>
          <div v-for="(st, stindex) in startList" :key="stindex" class="submit-btn-list">
            <Button
              size="large"
              style="width:190px;"
              class="overflow"
              @click="selecStartStep(st)"
            >{{ st.name }}</Button>
          </div>
        </div>
      </template>
    </TsDialog>
    <!-- 回退 -->
    <TsDialog
      type="modal"
      :isShow.sync="backModal"
      :className="stepDialogClass"
      :title="actionConfig.back"
      @on-ok="backOk"
    >
      <template>
        <div class="step-list">
          <TsForm ref="backForm" :itemList="backList" labelPosition="top">
            <template v-slot:step>
              <StepSelect :id="selectBackConfig.id" :list="backStepList" @selecStep="(val)=>{selecStep(val, 'back')}"></StepSelect>
            </template>
          </TsForm>
        </div>
      </template>
    </TsDialog>
    <TsDialog
      type="modal"
      :isShow.sync="assignModal"
      :className="stepDialogClass"
      :title="assignTitle"
      @on-ok="assignOk"
    >
      <template>
        <TsFormItem
          v-for="(item, index) in assignableWorkerStepList"
          :key="index"
          :label="item.name"
          :labelWidth="150"
          :validateList="item.isRequired ? validateList : ''"
          class="input-border"
        >
          <UserSelect
            v-model="item.value"
            transfer
            :groupList="assignGroupList"
            :validateList="item.isRequired ? validateList : []"
            width="90%"
          ></UserSelect>
        </TsFormItem>
      </template>
    </TsDialog>
    <!-- 转报 -->
    <RanferreportDialog v-if="actionConfig.tranferreport" :isShow.sync="ranferreportModel" :processTaskConfig="processTaskConfig"></RanferreportDialog>
    <RedoDialog :isShow.sync="redoModel" :processTaskConfig="processTaskConfig"></RedoDialog>
    <KnowledgeDialog :isShow.sync="knowledgeModel" :processTaskConfig="processTaskConfig"></KnowledgeDialog>
  </div>
</template>

<script>
import '@/views/pages/process/flow/topoComponent/index.js';
import clipboard from '@/resources/directives/clipboard.js';
import itemDialog from './workorder/actiondialog/index.js';
import detailmixin from './detailmixin.js';
import FooterOperationBtn from './workorder/footer-operation-btn.vue'; // 底部操作按钮组件

let Vm;

export default {
  //工单处理
  name: '',
  tagComponent: 'taskDeal', //主要用来标识是上报页面，为表单修改优先级做标志
  components: {
    TsDialog: resolve => require(['@/resources/plugins/TsDialog/TsDialog.vue'], resolve),
    TsForm: resolve => require(['@/resources/plugins/TsForm/TsForm.vue'], resolve),
    CenterDetail: resolve => require(['./workorder/CenterDetail.vue'], resolve),
    RightSetting: resolve => require(['./workorder/RightSetting.vue'], resolve),
    TsFormItem: resolve => require(['@/resources/plugins/TsForm/TsFormItem.vue'], resolve),
    UserSelect: resolve => require(['@/resources/components/UserSelect/UserSelect.vue'], resolve),
    ...itemDialog,
    NavTop: resolve => require(['./navTop.vue'], resolve),
    TaskAlert: resolve => require(['@/views/pages/process/task/processdetail/workorder/alert/top-alert.vue'], resolve),
    AutoDetail: resolve => require(['@/views/pages/process/task/processdetail/workorder/taskdetail-auto.vue'], resolve),
    CommonStatus: resolve => require(['@/resources/components/Status/CommonStatus.vue'], resolve),
    StepSelect: resolve => require(['@/views/pages/process/task/processdetail/workorder/common/step-select.vue'], resolve),
    FooterOperationBtn
  },
  provide() {
    return {
      $taskBox: this
    };
  },
  directives: {
    clipboard
  },
  mixins: [detailmixin],
  props: {},
  data() {
    return {
      ranferreportModel: false, // 转报弹框
      redoModel: false, //评分工单回退
      knowledgeModel: false,
      knowledgeConfig: null,
      transferStepList: [], //转交步骤列表
      transferId: null,
      taskAlertHeight: 0 // taskAlert高度
      // taskForm: null, //工单表单查看权限
    };
  },
  created() {
  },
  mounted() {
    this.getAllData();
    this.getKnowledgeDetail(); //转知识权限
    Vm = this;
  },
  beforeDestroy() {
    clearInterval(this.timer);
    this.timer = null;
  },
  methods: {
    getMessage() { 
      //单独处理当前步骤特有信息
    },
    async completeTask() {
      //流转
      let val = this.$refs.TaskCenterDetail ? this.$refs.TaskCenterDetail.getTaskStepContent() : null;
      this.completeList.forEach(item => {
        if (item.name == 'content') {
          item.value = val;
          if (this.isStepRequired === 0) {
            item.validateList = [];
          }
        }
      });
      let isValid = await this.taskValid();
      if (isValid) {
        this.nextStepList.length && this.selecStep(this.nextStepList[0]);
        this.completeModal = true;
      }
    },
    async completeOk() {
      //流转完成
      let completeForm = this.$refs.completeForm;
      if (completeForm.valid()) {
        await this.saveTaskData(true);
        let obj = completeForm.getFormValue();
        let isSave = true;
        for (let i = 0; i < this.assignableWorkerStepList.length; i++) {
          if (this.assignableWorkerStepList[i].isRequired == 1 && !this.assignableWorkerStepList[i].value.length) {
            isSave = false;
            this.$Notice.error({
              title: this.$t('form.placeholder.pleaseselect', {target: this.$t('term.process.stepuser')}),
              duration: 1.5
            });
            break;
          }
        }
        if (isSave) {
          let data = {
            processTaskId: this.processTaskId,
            processTaskStepId: this.processTaskStepId,
            nextStepId: this.selectStepConfig.id,
            content: obj.content,
            action: 'complete'
          };
          if (this.assignableWorkerStepList.length > 0) {
            let userArr = [];
            this.assignableWorkerStepList.forEach(a => {
              if (a.value && a.value.length > 0) {
                let userObj = {};
                userObj.processTaskStepId = a.id;
                userObj.workerList = a.value;
                userArr.push(userObj);
              }
            });
            if (userArr.length > 0) {
              data.assignWorkerList = userArr;
            }
          }
          if (!this.disabledConfig.completing) {
            this.disabledConfig.completing = true;
            this.$api.process.processtask.complete(data).then(res => {
              this.disabledConfig.completing = false;
              if (res.Status == 'OK') {
                this.$Message.success(this.$t('message.executesuccess'));
                this.completeModal = false;
                this.toTask(this.processTaskId);
              }
            }).catch(error => {
              this.disabledConfig.completing = false;
            });
          }
        }
      }
    },
    saveCompleData() {
      if (!this.disabledConfig.completing) {
        let conntent = this.$refs.TaskCenterDetail ? this.$refs.TaskCenterDetail.getTaskStepContent() : null;
        let data = {
          processTaskId: this.processTaskId,
          processTaskStepId: this.processTaskStepId,
          nextStepId: this.nestStepId,
          content: conntent,
          action: 'complete'
        };
        if (this.assignableWorkerStepList.length > 0) {
          let userArr = [];
          this.assignableWorkerStepList.forEach(a => {
            if (a.value && a.value.length > 0) {
              let userObj = {};
              userObj.processTaskStepId = a.id;
              userObj.workerList = a.value;
              userArr.push(userObj);
            }
          });
          if (userArr.length > 0) {
            data.assignWorkerList = userArr;
          }
        }
        this.disabledConfig.completing = true;
        this.$api.process.processtask.complete(data).then(res => {
          this.disabledConfig.completing = false;
          if (res.Status == 'OK') {
            this.$Message.success(this.$t('message.executesuccess'));
            this.toTask(this.processTaskId);
          }
        }).catch(error => {
          this.disabledConfig.completing = false;
        });
      }
    },
    //评分前回退
    redoTask() {
      this.redoModel = true;
    },
    createKnowledge() {
      //创建知识
      this.knowledgeModel = true;
    },
    getKnowledgeDetail() {
      //获取工单知识信息
      let moduleList = JSON.parse(localStorage.getItem('moduleList'));
      let find = moduleList.find(d => d.moduleId == 'knowledge');
      if (find && (this.processTask.status == 'succeed' || this.processTask.status == 'scored')) {
        //工单：完成或者评分状态时，都需要调知识接口
        let data = {
          invokeId: this.processTaskId,
          source: 'processtask'
        };
        this.$api.process.processtask.knowledgeDetail(data).then(res => {
          if (res.Status == 'OK') {
            let obj = res.Return;
            this.knowledgeConfig = obj;
          }
        });
      }
    },
    //auto
    autoRetry() {
      let data = {
        processTaskStepId: this.processTaskStepId
      };
      this.$api.process.processtask.retryAuto(data).then(res => {
        if (res.Status == 'OK') {
          this.$Message.success(this.$t('message.executesuccess'));
          this.$router.push({
            path: '/task-detail',
            query: {
              processTaskId: this.processTaskId,
              type: Date.now()
            }
          });
        }
      });
    }
  },
  computed: {
    isMoreAction() {
      //更多操作按钮
      let actionConfig = this.actionConfig;
      let moreAction = false;
      if (actionConfig.createsubtask || actionConfig.retreat || actionConfig.abortprocessTask || actionConfig.recoverprocessTask || actionConfig.urge || actionConfig.tranferreport || actionConfig.copyprocesstask || (this.knowledgeConfig && this.knowledgeConfig.isTransferKnowledge == 1)) {
        moreAction = true;
      }
      return moreAction;
    }
  },

  watch: {}
};
</script>

<style lang="less" scoped>
.task-title{
  font-size: 16px;
}
.task-main{
  position: relative;
  width: 100%;
  height: 100%;
  overflow-y: hidden;
  .callback-audit{
    border-top:1px solid;
    padding-top: 16px;
    margin-top: 16px;
  }
  .automatic-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    .automatic-status{
      padding-left: 6px;
    }
  }
}
.channel-type{
  padding: 4px 12px;
  margin-right: 4px;
  border-radius: 20px;
}
/deep/ .ivu-layout-content{
  overflow-y: hidden !important;
}
.retry-btn{
  text-align: right;
  margin-top: 16px;
}
</style>
